﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Controls;

namespace AOUtils.Libraries
{
    public class EquipmentGrid : Grid
    {
        private Dictionary<Slot, int> panelIndexes = new Dictionary<Slot, int>();
        public EquipmentGrid() : base()
        {
            int i = 0;
            foreach (IconDockPanel panel in Children)
            {
                panelIndexes.Add(panel.Slot, i);
                i++;
            }
        }
        public IEnumerable<int> GetPanelIndexes(Slot slot)
        {
            if (panelIndexes.Count == 0)
            {
                int i = 0;
                foreach (IconDockPanel panel in Children)
                {
                    panelIndexes.Add(panel.Slot, i);
                    i++;
                }
            }
            string[] values = slot.ToString().Split(new string[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries);
            List<int> indexes = new List<int>();
            foreach (string str in values)
            {
                indexes.Add(panelIndexes[(Slot)Enum.Parse(typeof(Slot), str)]);
            }
            return indexes.ToArray();
        }
    }
}
